package simplelab;

import jason.asSemantics.*;
import jason.asSyntax.*;

/*
 * This class is responsible for the "katz.Action(A,B,C)"
 * function in Jason.
 */
public class Action extends DefaultInternalAction {

    // My Knowledge
    public static World world = new World();

    @Override
    public Object execute(TransitionSystem ts, final Unifier un, final Term[] arg) throws Exception {
        final Beliefs beliefs = new Beliefs(ts.getAg().getBB().toString());

        Command command =
                world.Manage(beliefs);

        //RefreshDebugWin();
		/*javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
        debugMap.createAndShowGUI(beliefs.pos, beliefs.dir);
        }
        });*/

        NumberTermImpl actionType = new NumberTermImpl(command.actionType.ordinal()),
                p1 = new NumberTermImpl(command.param1),
                p2 = new NumberTermImpl(command.param2);

        return (un.unifies(actionType, arg[0]) && un.unifies(p1, arg[1])
                && un.unifies(p2, arg[2]));
    }
}